﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Skyhook.Logic.VisualControllers;
using Microsoft.Xna.Framework;
using Skyhook.Core;
using Skyhook.Resources;
using Skyhook.Logic;
using Skyhook.AI.MovingObjects;

namespace Skyhook.Logic
{
    class MovableObject<T> : LogicObject<T> where T : VisualController, new()
    {
        MovingEntity Mover = null;
        public delegate void StopEvent(MovableObject<T> sender);
        public event StopEvent OnStopEvent;
        
        public MovableObject(string assetname, int startx, int starty, float speed, float rotatespeed)
            : base(assetname, startx, starty)
        {
            Mover = new MovingEntity(ObjectController, speed);
        }    

        protected virtual void OnRotate(int angle)
        {
        }
        protected virtual void OnStop()
        {
            if (OnStopEvent != null)
            {
                OnStopEvent(this);
            }
        }

        public virtual void Update(float elapsedticks)
        {
            Mover.Update(elapsedticks);

            if (Mover.IsFinished)
            {
                OnStop();
            }
        }

        public void MoveToPoint(int x, int y)
        {
            Mover.MoveToPoint(x, y);
        }

        public void RotateToPoint(Vector2 point)
        {
            //Mover.RotateToPoint(point);
        }
    }
}
